//
//  ByConfirmUpdateView.m
//  recordworktool_ios
//
//  Created by mc on 2017/12/12.
//  Copyright © 2017年 ZhangZhanbin. All rights reserved.
//

#import "ByConfirmUpdateView.h"

@implementation ByConfirmUpdateView

- (id)init{
    self = [super init];
    if (self) {
        [self initViews];
    }
    return self;
}

- (void)initViews{
    // 设置弹出方式和位置
    self.positionMode = ZKBombPositionModeCenter;
    self.popMode = ZKBombPopModeTop;
    
    // 自定义视图
    UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH - 80, 160)];
    contentView.backgroundColor = [UIColor whiteColor];
    contentView.layer.cornerRadius = 20;
    
    UILabel *titleLabel = [[UILabel alloc] init];
    [contentView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(contentView).offset(0);
        make.right.equalTo(contentView).offset(0);
        make.bottom.equalTo(contentView.mas_centerY).offset(-15);
        make.height.mas_equalTo(@20);
    }];
    titleLabel.font = FONT(16);
    titleLabel.textColor = TEXT_COLOR;
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = @"是否确认修改";
    
    UIButton *YesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [contentView addSubview:YesBtn];
    [YesBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleLabel.mas_bottom).offset(20);
        make.right.equalTo(contentView.mas_centerX).offset(-20);
        make.size.mas_equalTo(CGSizeMake(70, 30));
    }];
    YesBtn.backgroundColor = BY_THEME_COLOR;
    YesBtn.layer.cornerRadius = 15;
    YesBtn.titleLabel.font = FONT(14);
    [YesBtn setTitle:@"是" forState:UIControlStateNormal];
    [YesBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    YesBtn.tag = 100;
    [YesBtn addTarget:self action:@selector(btnAciton:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *noBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [contentView addSubview:noBtn];
    [noBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleLabel.mas_bottom).offset(20);
        make.left.equalTo(contentView.mas_centerX).offset(20);
        make.size.mas_equalTo(CGSizeMake(70, 30));
    }];
    noBtn.backgroundColor = [UIColor whiteColor];
    noBtn.layer.cornerRadius = 15;
    noBtn.titleLabel.font = FONT(14);
    noBtn.layer.borderColor = BY_THEME_COLOR.CGColor;
    noBtn.layer.borderWidth = 1;
    noBtn.tag = 200;
    [noBtn setTitle:@"否" forState:UIControlStateNormal];
    [noBtn setTitleColor:BY_THEME_COLOR forState:UIControlStateNormal];
    [noBtn addTarget:self action:@selector(btnAciton:) forControlEvents:UIControlEventTouchUpInside];
    
    self.contentView = contentView;
    
}

- (void)btnAciton:(UIButton *)btn{
    if (btn.tag == 100) {
        self.yes();
    }else if (btn.tag == 200){
        self.no();
    }
    [self remove];
}

@end
